package com.catjiu.common.entity;

import com.catjiu.common.enums.ResultCode;

/**
 * <br>类描述：
 * <br>author： lwl liuwanli_eamil@163.com	2019/6/24 20:20
 *
 * @ClassName Result
 * @see #
 * @since {修改人、修改时间、修改事由}
 */
public class Result<T> {
    private int code;
    private String msg;
    private T content;
    private Result<T> setContent(T content) {
        this.content = content;
        return this;
    }

    private static Result getInstance(int code){
        Result r = new Result();
        r.setCode(code);
        return r;
    }

    public String getMsg() {
        return msg;
    }
    public static Result unlogin(){
        return getInstance(ResultCode.UN_LOGIN);
    }
    public static Result ok(){
        return getInstance(ResultCode.SUCCESS);
    }

    public static Result warning(){
        return getInstance(ResultCode.SUCCESS);
    }

    public static Result error(int code){
        return getInstance(code);
    }

    public static Result error(){
        return getInstance(ResultCode.FAIL);
    }

    public static Result redirect(){
        return getInstance(ResultCode.REDIRECT);
    }

    public Result msg(String msg){
        this.msg = msg;
        return this;
    }

    public Result content(T content){
        this.content = content;
        return this;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getContent() {
        return content;
    }
}
